//
//  ZJPoliticsBirthdayView.m
//  ShangHaiHuDongApp
//
//  Created by ZJ on 2017/7/26.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ZJPoliticsBirthdayView.h"

@interface ZJPoliticsBirthdayView ()
/** BGview */
@property (nonatomic, strong) UIImageView *imageView;

/** 我的历程 */
@property (nonatomic, strong) UIButton *button1;
/** 入党的那一天 */
@property (nonatomic, strong) UIButton *button2;
/** 退出按钮 */
@property (nonatomic, strong) UIButton *button3;
@end

@implementation ZJPoliticsBirthdayView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor zj_colorWithHexString:@"000000" alpha:0.5];
        
        [self addSubview:self.imageView];
        [self addSubview:self.time];
        [self addSubview:self.button1];
        [self addSubview:self.button2];
        [self addSubview:self.button3];
        
    }
    return self;
}

#pragma mark - 点击事件
//我的历程
- (void)action_myCourse{
    if (self.delegate) {
        [self.delegate ZJPoliticsBirthdayViewDelegate_myCourse];
    }
}
//入党那一天
- (void)action_time{
    if (self.delegate) {
        [self.delegate ZJPoliticsBirthdayViewDelegate_time];
    }
}
//退出
- (void)action_canle{
    if (self.delegate) {
        [self.delegate ZJPoliticsBirthdayViewDelegate_canle];
    }
}

- (UIImageView *)imageView{
    if (_imageView == nil){
        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20 * [UIScreen zj_screenWScale],47.5 * [UIScreen zj_screenHScale], self.width - 40 * [UIScreen zj_screenWScale], self.height - 47.5 * 2 * [UIScreen zj_screenHScale])];
        _imageView.image = [UIImage imageNamed:@"birthday_bg"];
    }
    return _imageView;
}
- (UILabel *)time{
    if (_time == nil){
        _time = [[UILabel alloc] initWithFrame:CGRectMake(0, 188 * [UIScreen zj_screenHScale], self.width, 10)];
        _time.textColor = [UIColor zj_colorWithHexString:@"d90000"];
        _time.font = [UIFont boldSystemFontOfSize:18 * [UIScreen zj_textFontScale]];
        _time.height = [NSString heightWithTextFont:_time.font];
        _time.textAlignment = NSTextAlignmentCenter;
    }
    return _time;
}
- (UIButton *)button1{
    if (_button1 == nil){
        _button1 = ({
            UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(50 * [UIScreen zj_screenWScale], 530 * [UIScreen zj_screenHScale], 130 * [UIScreen zj_screenWScale], 44 * [UIScreen zj_screenHScale])];
            [button addTarget:self action:@selector(action_myCourse) forControlEvents:UIControlEventTouchUpInside];
            button;
        });
    }
    return _button1;
}
- (UIButton *)button2{
    if (_button2 == nil){
        _button2 = ({
            UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(self.width - (50 + 130) * [UIScreen zj_screenWScale], self.button1.y, self.button1.width, self.button1.height)];
            [button addTarget:self action:@selector(action_time) forControlEvents:UIControlEventTouchUpInside];
            button;
        });
    }
    return _button2;
}
- (UIButton *)button3{
    if (_button3 == nil){
        _button3 = ({
            UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0,0,44 * [UIScreen zj_screenHScale], 44 * [UIScreen zj_screenHScale])];
            button.y = self.imageView.bottom - 12 * [UIScreen zj_screenHScale];
            button.centerX = self.imageView.centerX;
            [button addTarget:self action:@selector(action_canle) forControlEvents:UIControlEventTouchUpInside];
            [button setImage:[UIImage imageNamed:@"birthday_close"] forState:UIControlStateNormal];
            button;
        });
    }
    return _button3;
}

@end
